package com.ocom.webapi.controller;

import com.ocom.common.constant.HumanServiceUrl;
import com.ocom.common.resp.Result;
import com.ocom.webapi.service.VisitorApproverService;
import com.ocom.webapi.vo.visitorapprover.AddVo;
import com.ocom.webapi.vo.visitorapprover.ModifyVo;
import com.ocom.webapi.vo.visitorapprover.OnShowVo;
import com.ocom.webapi.vo.visitorapprover.RemoveVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

//@Slf4j
@RestController
@PreAuthorize("@pms.hasRole('ROLE_WEB')" )
public class VisitorApproverController {
    private final Logger log = LoggerFactory.getLogger(VisitorApproverController.class);

    @Autowired
    private VisitorApproverService visitorApproverService;

    /**
     * 审批负责人列表（VisitorApprover/onShow）
     * */
    @PostMapping(HumanServiceUrl.URL_VisitorApproverOnShow)
    public Result VisitorApproverOnShow(@Validated @RequestBody OnShowVo onShowVo){
        log.info("审批负责人列表请求参数:{{}}",onShowVo);
        return visitorApproverService.VisitorApproverOnShow(onShowVo);
    }

    /**
     * 新增审批负责人（VisitorApprover/add）
     * */
    @PostMapping(HumanServiceUrl.URL_VisitorApproverAdd)
    public Result VisitorApproverAdd(@Validated @RequestBody AddVo addVo){
        log.info("新增审批负责人请求参数:{{}}",addVo);
        return visitorApproverService.VisitorApproverAdd(addVo);
    }

    /**
     * 修改审批负责人（VisitorApprover/modify）
     * */
    @PostMapping(HumanServiceUrl.URL_VisitorApproverModify)
    public Result VisitorApproverModify(@Validated @RequestBody ModifyVo modifyVo){
        log.info("修改审批负责人请求参数:{{}}",modifyVo);
        return visitorApproverService.VisitorApproverModify(modifyVo);
    }

    /**
     * 删除审批负责人（VisitorApprover/remove）
     * */
    @PostMapping(HumanServiceUrl.URL_VisitorApproverRemove)
    public Result VisitorApproverRemove(@Validated @RequestBody RemoveVo removeVo){
        log.info("删除审批负责人请求参数:{{}}",removeVo);
        return visitorApproverService.VisitorApproverRemove(removeVo);
    }
}
